home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Communication / GatorGeo / Source / Subprocess.h < prev    next >
Text File  |  1990-10-28  |  2KB  |  74 lines

  1. /*
  2.     Subprocess.h    (v10)
  3.     by Charles L. Oei
  4.     pty support by Joe Freeman
  5.     with encouragement from Kristofer Younger
  6.     Subprocess Example, Release 2.0
  7.     NeXT Computer, Inc.
  8.  
  9.     You may freely copy, distribute and reuse the code in this example.
  10.     NeXT disclaims any warranty of any kind, expressed or implied, as to
  11.     its fitness for any particular use.
  12. */
  13.  
  14. #import <objc/Object.h>
  15. #import <stdio.h>
  16.  
  17. /*
  18.     This subprocess object sends/receives data to/from any UNIX
  19.     subprocess asynchronously (via vfork/pipe).
  20.     Its delegate, if any, will receive the following messages:
  21.  
  22.     - subprocessDone;
  23.         // sent when the subprocess exits
  24.     
  25.     - subprocessOutput:(char *)buffer;
  26.         // sent whenever there is data on the standard output pipe;
  27.         // buffer is only valid until next call
  28.     
  29.     - subprocessError:(const char *)errorString;
  30.         // sent when an error occurs;
  31.         // if it ever happens, it's usually only at startup time
  32. */
  33.  
  34.  
  35. #define BUFFERSIZE 2048
  36.  
  37. @interface Subprocess:Object
  38. {
  39.     FILE *fpToChild;
  40.     int fromChild;
  41.     int childPid;
  42.     id delegate;
  43.     int masterPty;    // file descriptor for master/slave pty
  44.     int slavePty;
  45.     int bufferCount;
  46.     char outputBuffer[BUFFERSIZE];
  47. }
  48.  
  49. - init:(const char *)subprocessString;
  50.     // a cover for the below withDelegate:nil, andPtySupport:NO, andStdErr:YES
  51.  
  52. - init:(const char *)subprocessString
  53.     withDelegate:theDelegate
  54.     andPtySupport:(BOOL)wantsPty
  55.     andStdErr:(BOOL)wantsStdErr;
  56.     // optional requests for pseudo terminal support and
  57.     // redirecting the standard error stream thru standard output
  58.  
  59. - send:(const char *)string withNewline:(BOOL)wantNewline;
  60.     // send the string optionally followed by a new line
  61. - send:(const char *)string;
  62.     // sends the string followed by a new line
  63.     // shorthand for above withNewline:YES
  64. - terminateInput;
  65.     // sends an end-of-file (EOF) to the subprocess
  66.     // (and closes input pipe to child)
  67. - terminate:sender;
  68.     // forces the subprocess to terminate (w/ SIGTERM)
  69.  
  70. - setDelegate:anObject;
  71. - delegate;
  72.  
  73. @end
  74.